strtotime
Parses any English text date-time description to Unix timestamp
strtotime()
function parses the date or time description of any English text into a Unix timestamp (seconds since January 1 1970 00:00:00 GMT).
Note: If the year indicates a two-digit format, the value 0-69 will be mapped to 2000-2069 and the value 70-100 will be mapped to 1970-2000.
Note: Note the dates in m/d/y or dmy format, and if the delimiter is a slash (/), the m/d/y format of America is used. If the separator is a horizontal bar (-) or a dot (.), then the European dmy format is used. To avoid potential errors, you should use the YYYY-MM-DD format whenever possible or use date_create_from_format()
function.
Parses the English text date and time to a Unix timestamp:
<?php echo ( strtotime ( "now" ) . "<br>" ) ; echo ( strtotime ( "15 October 1980" ) . "<br>" ) ; echo ( strtotime ( "+5 hours" ) . "<br>" ) ; echo ( strtotime ( "+1 week" ) . "<br>" ) ; echo ( strtotime ( "+1 week 3 days 7 hours 5 seconds" ) . "<br>" ) ; echo ( strtotime ( "next Monday" ) . "<br>" ) ; echo ( strtotime ( "last Sunday" ) ) ; ?>
Try it yourself
strtotime ( time , now ) ;
parameter | describe |
---|---|
time | Required. Specify date/time string. |
Now | Optional. Specifies the timestamp used to calculate the return value. If this parameter is omitted, the current time is used. |